home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / Visual Cafe Pro v1.0 / SOURCE.BIN / Ellipse.java < prev    next >
Encoding:
Java Source  |  1997-06-19  |  1.9 KB  |  77 lines

  1. package symantec.itools.awt.shape;
  2.  
  3.  
  4. import java.awt.Graphics;
  5. import java.awt.Color;
  6.  
  7.  
  8. /**
  9.  * This class forms the Ellipse shape component.
  10.  * @see symantec.itools.awt.shape.Circle
  11.  * @version 1.0, Nov 26, 1996
  12.  * @author Symantec
  13.  */
  14.  
  15. public class Ellipse
  16.     extends Shape
  17. {
  18.     /**
  19.      * Constructs a default Ellipse.
  20.      */
  21.     public Ellipse()
  22.     {
  23.     }
  24.  
  25.     /**
  26.      * Paints the ellipse using the given graphics context.
  27.      * This is a standard Java AWT method which typically gets called
  28.      * by the AWT to handle painting this component. It paints this component
  29.      * using the given graphics context. The graphics context clipping region
  30.      * is set to the bounding rectangle of this component and its <0,0>
  31.      * coordinate is this component's top-left corner.
  32.      *
  33.      * @param g the graphics context used for painting
  34.      * @see java.awt.Component#repaint
  35.      * @see java.awt.Component#update
  36.      */
  37.     public void paint(Graphics g)
  38.     {
  39.         g.clipRect(0, 0, width, height);
  40.  
  41.         int w = width - 1, h = height - 1;
  42.  
  43.         if (fill)
  44.         {
  45.             g.setColor(fillColor);
  46.             g.fillOval(0, 0, w, h);
  47.         }
  48.         else
  49.         {
  50.             switch (style) {
  51.  
  52.                 case BEVEL_LINE :
  53.                 default :
  54.                     g.drawOval(0, 0, w, h);
  55.                     break;
  56.  
  57.                 case BEVEL_LOWERED :
  58.                     g.setColor(Color.gray);
  59.                     g.drawArc(0, 0, w, h, 45, 180);
  60.  
  61.                     g.setColor(Color.white);
  62.                     g.drawArc(0, 0, w, h, 225, 180);
  63.                     break;
  64.  
  65.                 case BEVEL_RAISED :
  66.                     g.setColor(Color.white);
  67.                     g.drawArc(0, 0, w, h, 45, 180);
  68.  
  69.                     g.setColor(Color.gray);
  70.                     g.drawArc(0, 0, w, h, 225, 180);
  71.                     break;
  72.             }
  73.         }
  74.     }
  75. }
  76.  
  77.